package com.tmc.dao.impl.intcar;

import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.tmc.bean.common.ContextInfo;
import com.tmc.dao.impl.BaseDaoImpl;
import com.tmc.entity.intcar.IntcarOrder;
	
/**
 * @author zhang
 * @date 2017年12月19日 下午3:39:27 
 */
@Repository
public class IntcarOrderDaoImpl extends BaseDaoImpl<IntcarOrder>{
	
	public IntcarOrder getByVenderOrderID(ContextInfo context,String vendorOrderID){
		StringBuilder sql = new StringBuilder();
		Map<String,Object> params = new HashMap<>();
		sql.append(" from IntcarOrder c where c.enabledFlag = 'Y' and c.vendorOrderID = :vendorOrderID");
		params.put("venderOrderID", vendorOrderID);
		return  this.get(sql.toString(), params);
	}
	
	public IntcarOrder getByOrderNum(ContextInfo context, String orderNum){
		StringBuilder sql = new StringBuilder();
		Map<String,Object> params = new HashMap<>();
		sql.append(" from IntcarOrder c where c.enabledFlag = 'Y' and c.orderNum = :orderNum");
		params.put("orderNum", orderNum);
		return this.get(sql.toString(), params);
	}
	
	public Long getTodayOrdersCount(ContextInfo context, String tag) {
		Map<String, Object> params = new HashMap<String, Object>();
		StringBuilder sql = new StringBuilder();
		sql.append(" select count(*) from IntcarOrder c where c.orderNum like :tag");
		params.put("tag", tag + "%");
		return this.get(sql.toString(), params);
	}
	
}
